#include <iostream>
#include <typeinfo>

class Base {
public:
    virtual void print() { std::cout << "Base class" << std::endl; }
    virtual ~Base() {}
};

class Derived : public Base {
    void print() override { std::cout << "Derived class" << std::endl; }
};

int main() {
    Base* b = new Derived();
    // 利用 RTTI 的 typeid 运算符来确认动态类型
    std::cout << "The type of b is: " << typeid(*b).name() << std::endl;
    // 输出指向对象的实际类型（Derived），这是多态性的直接体现

    delete b;
    return 0;
}